package com.dubbo.lian.cms.modules.app.service.impl;
 import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.dubbo.lian.cms.modules.app.Family;
import com.dubbo.lian.cms.modules.app.mapper.FamilyMapper;
import com.dubbo.lian.cms.modules.app.service.IFamilyService;
import com.dubbo.lian.cms.modules.app.User;
import com.dubbo.lian.cms.modules.app.service.IUserService;
import com.dubbo.lian.common.util.BaseR;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 /**
 * <p>
 *   服务实现类
 * </p>
 *
 * @author lian
 * @since 2016-12-29
 */
@Service
public class FamilyServiceImpl extends ServiceImpl<FamilyMapper, Family> implements IFamilyService {
    @Autowired
    IUserService userService;
    @Override
    public BaseR insertFamilyUser(JSONObject obj) {
        String phoneNumber = obj.getString("phoneNumber");
        String userid = obj.getString("userid");
        String familyName = obj.getString("familyName");
        EntityWrapper ew = new EntityWrapper();
        ew.where("phonenumber = {0}",phoneNumber);
        User user = userService.selectOne(ew);
        String familyUserid = user.getUserid();
        Family family = new Family();
        family.setUserid(familyUserid);
        family.setFgroup(userid);
        family.setIsuser(1);
        family.setFamilyname(familyName);
        super.insert(family);
        return null;
    }
}